class TipPanelView extends zysx.BaseView{
    private tipImg:eui.Image;

    private tipTop:eui.Label;

    private left_btn:eui.Button;

    private right_btn:eui.Button;
    
	private des:eui.Label;

	private shareData:any;

    public constructor(data?) {
		super(data);
		this.skinName = "TipPanelSkin";
	}

    public initComponent(): void {
		super.initComponent();
	}

	public initListener(): void {
		super.initListener();
	}

    public onOpen(data?): void {
		super.onOpen(data);
		this.initView();

		this.shareData = this.data || {};
	}
	private initView(): void {
		var flg = this.data;
		if(this.data){
			flg = this.data.flg || this.data;
		}
		if(flg == 1){
			//求助好友
			this.tipTop.text ="求助好友";
			this.left_btn.label = "立即求助";
			this.right_btn.label = "退出";
			this.tipImg.visible = false;
			this.des.text = "好友成功过关后，点击他分享的链接即可查看过关视频";
			this.addEvent(this.left_btn, egret.TouchEvent.TOUCH_TAP, this.shareQz, this);
			this.addEvent(this.right_btn, egret.TouchEvent.TOUCH_TAP, this.closeSelf, this);
		}else  if(flg == 2){
			this.des.visible = false;
			this.tipTop.text ="送给朋友过关秘籍";
			this.left_btn.label = "残忍拒绝";
			this.right_btn.label = "分享秘籍";
			this.addEvent(this.left_btn, egret.TouchEvent.TOUCH_TAP, this.toMy, this);
			this.addEvent(this.right_btn, egret.TouchEvent.TOUCH_TAP, this.shareGg, this);
		}else  if(flg == 3){
			this.tipTop.text ="收到过关秘籍";
			this.left_btn.label = "不想观看";
			this.right_btn.label = "观看秘籍";
			this.des.visible = false;
			this.addEvent(this.left_btn, egret.TouchEvent.TOUCH_TAP, this.closeSelf, this);
			this.addEvent(this.right_btn, egret.TouchEvent.TOUCH_TAP, this.showMj, this);
		}else  if(flg == 4){
			this.tipImg.visible = true;
			this.des.visible = false;
			this.tipTop.text ="收到朋友求助";
			this.left_btn.label = "残忍拒绝";
			this.right_btn.label = "帮助过关";
			this.tipImg.texture = RES.getRes("qiuzhu_png");
			this.addEvent(this.left_btn, egret.TouchEvent.TOUCH_TAP, this.closeSelf, this);
			this.addEvent(this.right_btn, egret.TouchEvent.TOUCH_TAP, this.helpMj, this);
		}else if(flg == 5){
			this.tipImg.visible = true;
			this.des.visible = false;
			this.tipImg.texture = RES.getRes("taibangle_png");
			this.tipTop.text = '秘籍真实太厉害了';
			this.left_btn.label = '分享秘籍';
			this.right_btn.label = '我来挑战';
			this.addEvent(this.left_btn, egret.TouchEvent.TOUCH_TAP, this.shareMj, this);
			this.addEvent(this.right_btn, egret.TouchEvent.TOUCH_TAP,this.toMy, this);
		}
	}

	//分享秘籍
	private shareMj(){
		this.shareData.target = Consts.TONG_GUAN;
		var that = this;
		ShareMgr.share({data: this.shareData, callback(){
			zysx.LayerMgr.ins.openView(ViewConst.PLAYVIEW, this.shareData, LayerType.UI);
			that.closeSelf();
		}});
	}

	//我来挑战
	private toMy(){
		zysx.LayerMgr.ins.openView(ViewConst.PLAYVIEW,1,LayerType.UI);
		this.closeSelf();
	}

	//帮助他人过关
	private helpMj(evt: egret.TouchEvent): void{
		zysx.LayerMgr.ins.openView(ViewConst.PLAYVIEW, this.shareData, LayerType.UI);
		this.closeSelf();
	}

	//查看过关秘籍
	private showMj(evt: egret.TouchEvent): void{
		zysx.LayerMgr.ins.openView(ViewConst.PLAYVIEW, this.shareData, LayerType.UI);
		this.closeSelf();
	}

	//分享通关
	private shareGg(evt: egret.TouchEvent): void{
		var that = this;
		this.shareData.target = Consts.TONG_GUAN;
		ShareMgr.share({data: this.shareData, callback(){
			zysx.LayerMgr.ins.openView(ViewConst.PLAYVIEW,1,LayerType.UI);
			that.closeSelf();
		}});
	}

	//分享求助
	private shareQz(evt: egret.TouchEvent): void{
		this.shareData.target = Consts.HELP;
		var that = this;
		ShareMgr.share({data: this.shareData, callback(){
			that.closeSelf();
		}});
	}

    private openView(evt: egret.TouchEvent): void {
		let viewName: string = "";
		let layType: number = LayerType.POP;
		let data = null;
		// switch (evt.currentTarget) {
		// 	case this.left_btn:
		// 		this.closeSelf();
		// 		break;
		// }
		
	}
}

window["TipPanelView"] = TipPanelView;